<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>加载中，请稍后...</title>

    <link type="text/css" rel="stylesheet" href="/css/all.css"/>
    <script language="javascript" src="/js/all.js"></script>

    <script>
        var client_id = getUrlParam("client_id");
        var scope = getUrlParam("scope");
        var redirect_uri = getUrlParam("redirect_uri");

        ajax.doAjax({
            type: "GET",
            async: false,
            url: urls.backend.oauth2Server.authorize,
            data: {client_id: client_id, response_type: "code", scope: scope, redirect_uri: redirect_uri},
            success: function(data, status, xhr){
                window.location.href = urls.front.oauth2Server.confirmScope + "?scope=" + scope;
            },
            error: function(xhr, textStatus, errorThrown){
                if (xhr.status === 401) {
                    // 返回401说明需要用户登录
                    window.location.href = urls.front.oauth2Server.login + "?scope=" + scope;
                } if (xhr.status === 403) {
                    // 返回403说明参数有错误
                    $("#error").html(xhr.responseText)
                } else {
                    ajax.defaultOnError(ajax.errMsg);
                }
            }
        })

    </script>
</head>
<body>
    <h2 id="error" class="middle"></h2>
</body>
</html>